TESS Background data¶
This notebook shows how to use BackgroundCube to get TESS Full Frame Images (FFI) scatter light component and Earth/Moon angles as pixel maps for every camera/ccd in the instrument.
This data could be used to train a machine learning model or used directly to correct the scatter light contribution in TESS cutouts.
In [1]:
Copied!
# basic imports
import os
import numpy as np
from tess_backml import BackgroundCube
import matplotlib.pyplot as plt
# increase animation frame limits
import matplotlib
matplotlib.rcParams["animation.embed_limit"] = 2**128
# basic imports
import os
import numpy as np
from tess_backml import BackgroundCube
import matplotlib.pyplot as plt
# increase animation frame limits
import matplotlib
matplotlib.rcParams["animation.embed_limit"] = 2**128
In [2]:
Copied!
# define sector/camera/ccd
sector = 2
camera = 2
ccd = 4
# define sector/camera/ccd
sector = 2
camera = 2
ccd = 4
We initialize the object with a specific Sectopr/Camera/CCD, an image bin size, and a method for downsizing (default if 'binning')
In [8]:
Copied!
bkg_data = BackgroundCube(
sector=sector, camera=camera, ccd=ccd, img_bin=16, downsize="binning"
)
print(bkg_data)
bkg_data = BackgroundCube(
sector=sector, camera=camera, ccd=ccd, img_bin=16, downsize="binning"
)
print(bkg_data)
TESS FFI Background object (Sector, Camera, CCD, N times): 2, 2, 4, 1245
Compute the binned scatter light cube which does:
- Finds the darkest frame in the sector to build a star mask and a saturated pixel mask
- Adds a strap mask
- Pulls the FFI flux data from the cloud
- Downsize the image by doing median 16x16 binning, masking out stars, straps, and saturated pixels
- The resulting scatter light cube has shape [nt, 128, 128]
In [7]:
Copied!
bkg_data.get_scatter_light_cube(frames=None, mask_straps=True, plot=True)
bkg_data.get_scatter_light_cube(frames=None, mask_straps=True, plot=True)
Computing sector darkest frames... Computing star mask...
Getting FFI flux cube... Computing average static scene from darkes frames...
Iterating frames: 100%|██████████| 1245/1245 [28:53<00:00, 1.39s/it]
We can animate the scatter light cube for visualization
In [8]:
Copied!
bkg_data.animate_data(data="sl", save=False, step=4)
bkg_data.animate_data(data="sl", save=False, step=4)
INFO:matplotlib.animation:Animation.save using <class 'matplotlib.animation.HTMLWriter'>
Out[8]: